package com.enki.cigarettes.repository;

import com.enki.cigarettes.entity.ProductFollowT;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.repository.PagingAndSortingRepository;

/**
 * @author WCS.Wang
 * @version V1.0
 * @Package com.enki.cigarettes.repository
 * @Name e-cigarettes-shop-api-module
 * @Description: TODO 商品收藏
 * @date 2019-07-19
 */
public interface ProductFollowTRepository extends PagingAndSortingRepository<ProductFollowT, String> {

    /**
     * 用户ID、商品ID
     *
     * @param userTId
     * @param productId
     * @return
     */
    ProductFollowT findOneByUserTIdAndProductId(String userTId, long productId);

    /**
     * 分页查询商品收藏
     *
     * @param specification
     * @param pageable
     * @return
     */
    Page<ProductFollowT> findAll(Specification specification, Pageable pageable);

    /**
     * 商品收藏数量
     *
     * @param userTId
     * @return
     */
    long countByUserTId(String userTId);

    /**
     * 关注的商品
     *
     * @param userTId
     * @param pageable
     * @return
     */
    Page<ProductFollowT> findByUserTId(String userTId, Pageable pageable);

}

